<!-- 新闻列表 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <div v-if="isshow">
      <dxtable
        :headBtn="headBtn"
        :dataJson="dataJson"
        :portUrl="portUrl"
        :qx="qx"
        ref="databale"
        sonRouter="xinglianaddComponent"
      ></dxtable>
    </div>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf } from "../../../util/index";
import { h, ref, reactive } from "vue";
const props = defineProps({
  pup: { type: String },
});
const isshow = ref();

let headBtn = [];
const zdList = ref();
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "产品名称",
    key: "title",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "产品特点",
    key: "productFeature",
    ellipsis: {
      tooltip: true,
    },
  },
  {
    title: "产品分类",
    key: "classify",
    width: 200,
    render(row) {
      const dataw = row.classify.split("&");
      let ster = "";
      zdList.value.map((a) => {
        if (a.id == dataw[0]) {
          const tetl = JSON.parse(a.text);
          ster = a.sxname;
          tetl.map((b) => {
            if (b.value == dataw[1]) {
              ster = ster + "->" + b.label;
            }
          });
        }
      });
      return ster;
    },
  },
  {
    title: "是否为热门",
    key: "hot",
    search: true, // 是否在搜索栏展示
    type: "select",
    width: 100,
    options: [
      {
        label: "全部",
        value: "",
      },
      {
        label: "是",
        value: 1,
      },
      {
        label: "否",
        value: 2,
      },
    ],
    render(row) {
      return row.hot == 1 ? "是" : "否";
    },
  },
  {
    title: "排序",
    width: 100,
    render(row) {
      row.databaseName = "xlxproduct";
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "创建时间",
    key: "addTime",
    width: "200",
    type: "daterange",
  },
]);
let portUrl = "xinglianxin/xlxproduct";
const qx = {
  DeletePermissionID: "xinglianxinproductlistdel", //删除
  EditPermissionIdentifier: "xinglianxinproductlistbj", // 编辑
  NewPermissionIdentifier: "xinglianxinproductlistxz", // 新建
  ViewPermissionID: "xinglianxinproductlistck", // 查看
};

let pupVal = props.pup;
if (pupVal) {
  headBtn = [
    {
      name: "确认选择 ",
      async clickFun(row) {
        const arrList = row.join(",");
        emit("callBack", arrList);
      },
    },
  ];
}
const getzdList = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd/getzdList", {
    ids: "109,110,111",
  });
  zdList.value = data;
  isshow.value = true;
};
getzdList();
</script>
